package org.xi.maple.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

public class MapleData implements Serializable {

    private  Map<String, String> env = new LinkedHashMap<>();
    private MapleDataConfig[] sources;
    private MapleDataConfig[] transformations;
    private MapleDataConfig[] sinks;

    public Map<String, String> getEnv() {
        return env;
    }

    public void setEnv(Map<String, String> env) {
        this.env = env;
    }

    public MapleDataConfig[] getSources() {
        return sources;
    }

    public void setSources(MapleDataConfig[] sources) {
        this.sources = sources;
    }

    public MapleDataConfig[] getTransformations() {
        return transformations;
    }

    public void setTransformations(MapleDataConfig[] transformations) {
        this.transformations = transformations;
    }

    public MapleDataConfig[] getSinks() {
        return sinks;
    }

    public void setSinks(MapleDataConfig[] sinks) {
        this.sinks = sinks;
    }

    public static class MapleDataConfig implements Serializable {

        private String name;
        private JSONObject config;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public JSONObject getConfig() {
            return config;
        }

        public void setConfig(JSONObject config) {
            this.config = config;
        }
    }

    public static MapleData getData(String data) {
        return JSON.parseObject(data, MapleData.class);
    }
}
